package com.zz.cc.owner.app;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.zz.cc.owner.R;
import com.zz.cc.owner.util.Util;

public class RegisterPhoneNumActivity extends Activity  implements OnClickListener {
	private EditText mPhoneNumInput,mUsernameInput,mPwdInput,mConfirmPwdInput;
	private Button mNextBtn;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_register_phone_num);
		initUI();
		fillView();
	}
	
	private void initUI() {
		((TextView)findViewById(R.id.titleTextView)).setText("填写注册信息");
		findViewById(R.id.backImg).setOnClickListener(this);
		mPhoneNumInput = (EditText) findViewById(R.id.phonenum_edittext);
		mUsernameInput = (EditText)findViewById(R.id.username_edittext);
		mPwdInput = (EditText)findViewById(R.id.pwd_edittext);
		mConfirmPwdInput = (EditText)findViewById(R.id.confirm_pwd_edittext);
		mNextBtn = (Button) findViewById(R.id.nextstep);
	}
	
	private void fillView() {
		mNextBtn.setOnClickListener(this);
	}

	@Override
	public void onClick(View view) {
		switch (view.getId()) {
		case R.id.nextstep:
			String account = mUsernameInput.getText().toString().trim();
			String phonenum = mPhoneNumInput.getText().toString().trim();
			String pwd = mPwdInput.getText().toString().trim();
			String confirmpwd = mConfirmPwdInput.getText().toString().trim();
			if (account.equals("") || phonenum.equals("") || pwd.equals("")
					|| confirmpwd.equals("")) {
				Util.showToast(this, "还有必填内容没有填写");
				return;
			}
			if (!pwd.equals(confirmpwd)) {
				Util.showToast(this, "两次密码必须相同");
				return;
			}
			
			Intent intent = new Intent(this, SelectCarToRegActivity.class);
			startActivity(intent);
			overridePendingTransition(R.anim.activity_slide_right_in, R.anim.activity_slide_left_out);
			break;
		case R.id.backImg:
			finish();
			break;
		}
	}
}
